package yqt.com.cnki.dao.impl;

import cnki.tpi.kbatis.sqlsession.SqlSession;
import cnki.tpi.kbatis.utils.DataSourceUtil;
import org.springframework.stereotype.Repository;
import yqt.com.cnki.bo.DownBo;
import yqt.com.cnki.bo.KnowledgeBo;
import yqt.com.cnki.bo.Nodebo;
import yqt.com.cnki.dao.KnowledgeYqtDao;

import java.util.List;

@Repository
public class KnowledgeYqtDaoImpl implements KnowledgeYqtDao {

    @Override
    public List<Nodebo> getNodeByTableName(String nodeCode) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.KnowledgeYqtDao.getNodeByTableName";
        return sqlSession.selectList(statementId, nodeCode, false);
    }

    @Override
    public List<KnowledgeBo> complexSearch(KnowledgeBo knowledgeBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.KnowledgeYqtDao.complexSearch";
        return sqlSession.selectList(statementId, knowledgeBo, true);
    }

    @Override
    public Long findComplexSearchCount(KnowledgeBo knowledgeBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.KnowledgeYqtDao.findComplexSearchCount";
        return sqlSession.getCount(statementId, knowledgeBo);
    }

    @Override
    public KnowledgeBo getBoByConditon(DownBo downBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.KnowledgeYqtDao.getBoByConditon";
        return sqlSession.selectOne(statementId, downBo, false);
    }

    @Override
    public Boolean updateByCondition(KnowledgeBo knowledgeBo) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.KnowledgeYqtDao.updateByCondition";
        return sqlSession.executeUpdate(statementId, knowledgeBo);
    }

    @Override
    public List<String> getCueWord(String inputWord) {
        SqlSession sqlSession = DataSourceUtil.getSqlSession();
        String statementId = "yqt.com.cnki.dao.KnowledgeYqtDao.getCueWord";
        return sqlSession.selectList(statementId, inputWord, false);
    }
}
